﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using WebComponents;
using WebComponents.Data;
using WebComponents.Security;
using System.Collections.Generic;
using GBIT.Web;

public partial class LienHeList : UserControlBase {
  private int index = -1;
  private List<ContactInfo> contactList = ContactController.List();
  protected void Page_Load(object sender, EventArgs e) {
    if (!Page.IsPostBack) {
      grvContact.DataSource = contactList;
      grvContact.DataBind();
    }
    this.DeleteEnabled = true;
    this.Title = "Danh sách thông tin liên hệ";
  }
  protected void grvContact_PageIndexChanging(object sender, GridViewPageEventArgs e) {
    grvContact.PageIndex = e.NewPageIndex;
    grvContact.DataSource = contactList;
    grvContact.DataBind();
  }
  protected void grvContact_Sorting(object sender, GridViewSortEventArgs e) {
    contactList.Sort(new ObjectComparer<ContactInfo>(e.SortExpression, ObjectComparer<ContactInfo>.AutoSortDirection));
    grvContact.DataSource = contactList;
    grvContact.DataBind();
  }
  protected override void OnDeleteRecord() {
    foreach (GridViewRow row in grvContact.Rows) {
      if (((CheckBox)row.FindControl("chkSelect")).Checked) {
        ContactController.Delete(ConvertType.ToInt(((CheckBox)row.FindControl("chkSelect")).ToolTip));
      }
    }
    grvContact.DataSource = ContactController.List();
    grvContact.DataBind();
  }
}
